import React from 'react';
import CommonPage from '@/components/page/CommonPage';
import { useModel } from 'umi';
const daoName = 'Zywhr';
const importName = 'Zywhrdr';
const importDaoName = 'Zywhrdr';
const columns: API.Column[] = [
  {
    title: '客户号',
    width: 150,
    sorter: true,
    key: 'CUNO',
    dataIndex: 'CUNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '客户姓名',
    width: 150,
    sorter: true,
    key: 'CUNM',
    dataIndex: 'CUNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工工号',
    width: 150,
    sorter: true,
    key: 'EMNO',
    dataIndex: 'EMNO',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '员工姓名',
    width: 110,
    sorter: true,
    key: 'EMNM',
    dataIndex: 'EMNM',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '维护人工号',
    width: 150,
    sorter: true,
    key: 'EMNO2',
    dataIndex: 'EMNO2',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '维护人姓名',
    width: 110,
    sorter: true,
    key: 'EMNM2',
    dataIndex: 'EMNM2',
    dispaly: true,
    filter: true,
    export: true,
  },
  {
    title: '机构号',
    width: 110,
    sorter: true,
    key: 'UTID',
    dataIndex: 'UTID',
    dispaly: true,
    filter: true,
    export: true,
  },
];

const controlsImport: API.Control[] = [
  { name: 'CUNO', type: 'text', label: '客户号', grid: 12 / 24 },
  { name: 'CUNM', type: 'text', label: '客户姓名', grid: 12 / 24 },
  { name: 'EMNO2', type: 'text', label: '维护人工号', grid: 12 / 24 },
  { name: 'EMNM2', type: 'text', label: '维护人姓名', grid: 12 / 24 },
];

const controls: API.Control[] = [
  { name: 'CUNO', type: 'text', label: '客户号', grid: 12 / 24 },
  { name: 'CUNM', type: 'text', label: '客户姓名', grid: 12 / 24 },
  { name: 'EMNO', type: 'text', label: '员工工号', grid: 12 / 24 },
  { name: 'EMNM', type: 'text', label: '员工姓名', grid: 12 / 24 },
  { name: 'EMNO2', type: 'text', label: '维护人工号', grid: 12 / 24 },
  { name: 'EMNM2', type: 'text', label: '维护人姓名', grid: 12 / 24 },
  { name: 'UTID', type: 'text', label: '机构号', grid: 12 / 24 },
];

const Zywhr: React.FC = () => {
  const { user } = useModel('@@initialState', (ret: any) => {
    return {
      user: ret.initialState?.user,
    };
  });
  const { permTypes } = useModel('sysInfo', (ret: any) => ({
    permTypes: ret.getCurPermTypes(),
  }));
  let where: string = '';
  if (permTypes.indexOf('3') != -1) {
    where = user.pOrgID;
  }
  return (
    <CommonPage
      daoName={daoName}
      columns={columns}
      controls={controls}
      title="掌银维护人"
      importName={importName}
      importDaoName={importDaoName}
      importControls={controlsImport}
      importMode="InsertAndUpdate"
      importTemplateName="掌银维护人导入模板"
      keyColName="ID"
      importKeys={['CUNO']}
      seeks={[
        {
          WhereItems: [
            {
              FieldName: 'UTID',
              Operator: '=',
              FieldValues: '' + where,
            },
          ],
          RelationSign: 'AND',
        },
      ]}
    />
  );
};
export default Zywhr;
